import { Entity, model, property, belongsTo } from '@loopback/repository';
import { Post } from './post.model';
import { User } from './user.model';
/**
 * 评论
 */
@model()
export class Comment extends Entity {
  @property({
    type: 'number',
    id: true,
  })
  id?: number;

  // @property({
  //   type: 'number',
  //   required: true,
  // })
  @belongsTo(() => Post)
  postId: number;

  // @property({
  //   type: 'number',
  //   required: true,
  // })
  @belongsTo(() => User)
  userId: number;

  @property({
    type: 'string',
    required: true,
  })
  username: string;

  // @property({
  //   type: 'number',
  //   required: true,
  // })
  @belongsTo(() => User)
  replyUserId: number;

  @property({
    type: 'string',
    required: true,
  })
  replyUsername: string;

  @property({
    type: 'string',
    required: true,
  })
  content: string;

  @property({
    type: 'number',
    required: true,
  })
  replyId: number;

  @property({
    type: 'date',
    required: true,
  })
  created: string;

  @property({
    type: 'number',
    required: true,
    default: 0,
  })
  likeCount: number;

  @property({
    type: 'number',
    required: true,
    default: 0,
  })
  replyCount: number;

  constructor(data?: Partial<Comment>) {
    super(data);
  }
}
